//
//  ThemeManager.swift
//  Stock_Stategy
//
//  Created by MayerF on 2017/9/7.
//  Copyright © 2017年 MayerF. All rights reserved.
//

import UIKit

extension UIColor {
    convenience init(colorValue: Int, alphaValue: Float) {
        self.init(_colorLiteralRed: (Float)(colorValue>>16&0xFF)/255.0, green: (Float)(colorValue>>8&0xFF)/255.0, blue: (Float)(colorValue&0xFF)/255.0, alpha: alphaValue)
    }
}

class ThemeManager: NSObject {
    //创建单例
    @objc static let manager = ThemeManager()
    private override init() {
    }
    //主题类型 0:日间；1：夜间。
    @objc var themeType = 0
    //获取主题图片
    //夜间图片名字前面多一个"night_"
    @objc func getThemeImage(name: String) -> String {
        var themeImage = name
        let pre = "night_"
        if name.hasPrefix(pre) {
            themeImage = themeImage.substring(from: pre.endIndex)
        }
        if themeType == 1 {
            themeImage = pre + themeImage
        }
        return themeImage
    }
    //大背景颜色
    @objc func getThemeBigBackgroundColor() -> UIColor {
        var newColor = UIColor(colorValue: 0xf5f5f5, alphaValue: 1)// 默认日间颜色
        if themeType == 1 {//夜间
            newColor = UIColor(colorValue: 0x13161e, alphaValue: 1)
        }
        return newColor
    }
    //通用背景颜色
    @objc func getThemeNormalBackgroundColor() -> UIColor {
        var newColor = UIColor.white// 默认日间颜色
        if themeType == 1 {//夜间
            newColor = UIColor(colorValue: 0x1e1e29, alphaValue: 1)
        }
        return newColor
    }
    /***************************************************************************
                                        首页
     ***************************************************************************/
    //首页Tabview字体颜色
    @objc func getThemeTabViewFontColor() -> UIColor {
        var newColor = UIColor(colorValue: 0x333333, alphaValue: 1)// 默认日间颜色
        if themeType == 1 {//夜间
            newColor = UIColor(colorValue: 0xb5bcde, alphaValue: 1)
        }
        return newColor
    }
    //首页header字体颜色
    @objc func getThemeHeaderFontColor() -> UIColor {
        var newColor = UIColor(colorValue: 0x999999, alphaValue: 1)// 默认日间颜色
        if themeType == 1 {//夜间
            newColor = UIColor(colorValue: 0x868fac, alphaValue: 1)
        }
        return newColor
    }
    //首页列表文本字体颜色
    @objc func getThemeHomeListTextFontColor() -> UIColor {
        var newColor = UIColor(colorValue: 0x999999, alphaValue: 1)// 默认日间颜色
        if themeType == 1 {//夜间
            newColor = UIColor(colorValue: 0x56596a, alphaValue: 1)
        }
        return newColor
    }
    //首页列表内容字体颜色
    @objc func getThemeHomeListTextContentFontColor() -> UIColor {
        var newColor = UIColor(colorValue: 0x333333, alphaValue: 1)// 默认日间颜色
        if themeType == 1 {//夜间
            newColor = UIColor(colorValue: 0x919ab9, alphaValue: 1)
        }
        return newColor
    }
    /***************************************************************************
     首页
     ***************************************************************************/
}
